{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import sqlalchemy\n",
    "from sqlalchemy import create_engine\n",
    "TABLE_FUND_DAY_K_DATA = \"shenge_money_fund_day_k_data\"\n",
    "\n",
    "def connect_db():\n",
    "    connect_info = 'mysql+pymysql://paqi:chs518518!@rm-bp1v9plylv4340as7qo.mysql.rds.aliyuncs.com:3306/paqi?charset=utf8'\n",
    "    engine = create_engine(connect_info)\n",
    "    return engine\n",
    "\n",
    "conn = connect_db()\n",
    "sql = \"SELECT  DISTINCT code FROM %s  \" % TABLE_FUND_DAY_K_DATA\n",
    "df = pd.read_sql(sql=sql,con=conn)\n",
    "df\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 375,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>code</th>\n",
       "      <th>name</th>\n",
       "      <th>tdate</th>\n",
       "      <th>open</th>\n",
       "      <th>close</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>ktype</th>\n",
       "      <th>id</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>513050</td>\n",
       "      <td>中概互联网etf</td>\n",
       "      <td>2018-12-10</td>\n",
       "      <td>1.13</td>\n",
       "      <td>1.121</td>\n",
       "      <td>1.131</td>\n",
       "      <td>1.118</td>\n",
       "      <td>101</td>\n",
       "      <td>206286</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>513050</td>\n",
       "      <td>中概互联网etf</td>\n",
       "      <td>2018-12-11</td>\n",
       "      <td>1.126</td>\n",
       "      <td>1.125</td>\n",
       "      <td>1.129</td>\n",
       "      <td>1.121</td>\n",
       "      <td>101</td>\n",
       "      <td>206287</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>513050</td>\n",
       "      <td>中概互联网etf</td>\n",
       "      <td>2018-12-12</td>\n",
       "      <td>1.135</td>\n",
       "      <td>1.138</td>\n",
       "      <td>1.139</td>\n",
       "      <td>1.133</td>\n",
       "      <td>101</td>\n",
       "      <td>206288</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>513050</td>\n",
       "      <td>中概互联网etf</td>\n",
       "      <td>2018-12-13</td>\n",
       "      <td>1.145</td>\n",
       "      <td>1.149</td>\n",
       "      <td>1.15</td>\n",
       "      <td>1.14</td>\n",
       "      <td>101</td>\n",
       "      <td>206289</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>513050</td>\n",
       "      <td>中概互联网etf</td>\n",
       "      <td>2018-12-14</td>\n",
       "      <td>1.143</td>\n",
       "      <td>1.13</td>\n",
       "      <td>1.143</td>\n",
       "      <td>1.128</td>\n",
       "      <td>101</td>\n",
       "      <td>206290</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>732</th>\n",
       "      <td>513050</td>\n",
       "      <td>中概互联网etf</td>\n",
       "      <td>2021-12-15</td>\n",
       "      <td>1.337</td>\n",
       "      <td>1.324</td>\n",
       "      <td>1.34</td>\n",
       "      <td>1.322</td>\n",
       "      <td>101</td>\n",
       "      <td>207018</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>733</th>\n",
       "      <td>513050</td>\n",
       "      <td>中概互联网etf</td>\n",
       "      <td>2021-12-16</td>\n",
       "      <td>1.319</td>\n",
       "      <td>1.311</td>\n",
       "      <td>1.319</td>\n",
       "      <td>1.308</td>\n",
       "      <td>101</td>\n",
       "      <td>207019</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>734</th>\n",
       "      <td>513050</td>\n",
       "      <td>中概互联网etf</td>\n",
       "      <td>2021-12-17</td>\n",
       "      <td>1.305</td>\n",
       "      <td>1.282</td>\n",
       "      <td>1.305</td>\n",
       "      <td>1.278</td>\n",
       "      <td>101</td>\n",
       "      <td>207020</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>735</th>\n",
       "      <td>513050</td>\n",
       "      <td>中概互联网etf</td>\n",
       "      <td>2021-12-20</td>\n",
       "      <td>1.281</td>\n",
       "      <td>1.249</td>\n",
       "      <td>1.281</td>\n",
       "      <td>1.245</td>\n",
       "      <td>101</td>\n",
       "      <td>209159</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>736</th>\n",
       "      <td>513050</td>\n",
       "      <td>中概互联网etf</td>\n",
       "      <td>2021-12-21</td>\n",
       "      <td>1.235</td>\n",
       "      <td>1.25</td>\n",
       "      <td>1.251</td>\n",
       "      <td>1.232</td>\n",
       "      <td>101</td>\n",
       "      <td>209160</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>737 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       code      name       tdate   open  close   high    low ktype      id\n",
       "0    513050  中概互联网etf  2018-12-10   1.13  1.121  1.131  1.118   101  206286\n",
       "1    513050  中概互联网etf  2018-12-11  1.126  1.125  1.129  1.121   101  206287\n",
       "2    513050  中概互联网etf  2018-12-12  1.135  1.138  1.139  1.133   101  206288\n",
       "3    513050  中概互联网etf  2018-12-13  1.145  1.149   1.15   1.14   101  206289\n",
       "4    513050  中概互联网etf  2018-12-14  1.143   1.13  1.143  1.128   101  206290\n",
       "..      ...       ...         ...    ...    ...    ...    ...   ...     ...\n",
       "732  513050  中概互联网etf  2021-12-15  1.337  1.324   1.34  1.322   101  207018\n",
       "733  513050  中概互联网etf  2021-12-16  1.319  1.311  1.319  1.308   101  207019\n",
       "734  513050  中概互联网etf  2021-12-17  1.305  1.282  1.305  1.278   101  207020\n",
       "735  513050  中概互联网etf  2021-12-20  1.281  1.249  1.281  1.245   101  209159\n",
       "736  513050  中概互联网etf  2021-12-21  1.235   1.25  1.251  1.232   101  209160\n",
       "\n",
       "[737 rows x 9 columns]"
      ]
     },
     "execution_count": 375,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "codes = list(df['code'])\n",
    "codes = codes[0:1]\n",
    "\n",
    "for code in codes:\n",
    "    code = '513050'\n",
    "    sql = \"SELECT  * FROM %s WHERE code= %s \" % (TABLE_FUND_DAY_K_DATA,code)\n",
    "    df_code = pd.read_sql(sql=sql,con=conn)\n",
    "    break\n",
    "\n",
    "df_code\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "var hq_str_sh510230=\"金融ETF,1.057,1.056,1.056,1.059,1.049,1.055,1.056,36791900,38752520.000,386900,1.055,277300,1.054,48700,1.053,35600,1.052,351500,1.051,233900,1.056,275000,1.057,229400,1.058,124800,1.059,165300,1.060,2021-12-23,15:00:03,00,\";\n",
      "\n",
      "{'name': '金融ETF', 'close': '1.056', 'open': '1.057', 'high': '1.059', 'low': '1.049'}\n"
     ]
    }
   ],
   "source": [
    "\n",
    "import requests\n",
    "code ='510230'\n",
    "r1 = requests.get(url=\"https://hq.sinajs.cn/list=sh600183\")\n",
    "r2 = requests.get(url=\"https://hq.sinajs.cn/list=sh510230\")\n",
    "print(r2.text)\n",
    "datas = str.split(r2.text,\"\\\"\")\n",
    "bbs = str.split(datas[1],\",\")\n",
    "detail ={}\n",
    "detail[\"name\"]= bbs[0]\n",
    "detail[\"close\"]= bbs[3]\n",
    "detail[\"open\"]=bbs[1]\n",
    "detail[\"high\"]=bbs[4]\n",
    "detail[\"low\"]=bbs[5]\n",
    "print(detail)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 276,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0      1.118\n",
       "1      1.118\n",
       "2      1.118\n",
       "3      1.118\n",
       "4      1.118\n",
       "       ...  \n",
       "730    1.311\n",
       "731    1.311\n",
       "732    1.311\n",
       "733    1.308\n",
       "734    1.278\n",
       "Length: 735, dtype: float64"
      ]
     },
     "execution_count": 276,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#SKDJ公式\n",
    "#获取前n天的最低价\n",
    "def LOW(df,n): \n",
    "    mins = []\n",
    "    for index,row in df.iterrows():\n",
    "        tdate = row['tdate']\n",
    "        dff = df[df['tdate']<=tdate]\n",
    "        if len(dff) >= n:\n",
    "            dff = dff.tail(n)\n",
    "        min = dff['low'].min()\n",
    "        mins.append(min)\n",
    "    return pd.Series(mins).astype('float')\n",
    "\n",
    "LOWV = LOW(df_code,9)\n",
    "LOWV"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 283,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0      1.131\n",
       "1      1.131\n",
       "2      1.139\n",
       "3      1.150\n",
       "4      1.150\n",
       "       ...  \n",
       "730    1.393\n",
       "731    1.386\n",
       "732    1.377\n",
       "733    1.368\n",
       "734    1.368\n",
       "Length: 735, dtype: float64"
      ]
     },
     "execution_count": 283,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#获取前n天的最高价\n",
    "def HIGH(df,n): \n",
    "    maxs = []\n",
    "    for index,row in df.iterrows():\n",
    "        tdate = row['tdate']\n",
    "        dff = df[df['tdate']<=tdate]\n",
    "        if len(dff) >= n:\n",
    "            dff = dff.tail(n)\n",
    "        max = dff['high'].max()\n",
    "        maxs.append(max)\n",
    "    return pd.Series(maxs).astype('float')\n",
    "HIGV = HIGH(df_code,9)\n",
    "HIGV"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 272,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0      1.121\n",
       "1      1.125\n",
       "2      1.138\n",
       "3      1.149\n",
       "4      1.130\n",
       "       ...  \n",
       "730    1.356\n",
       "731    1.333\n",
       "732    1.324\n",
       "733    1.311\n",
       "734    1.282\n",
       "Name: close, Length: 735, dtype: float64"
      ]
     },
     "execution_count": 272,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "df_float = df_code['close'].astype('float') \n",
    "df_float\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 286,
   "metadata": {},
   "outputs": [],
   "source": [
    "cal1 = (df_float-LOWV)\n",
    "cal2 = (HIGV-LOWV)\n",
    "cal1 = cal1 /cal2*100"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 287,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0            NaN\n",
       "1            NaN\n",
       "2      57.387057\n",
       "3      77.131029\n",
       "4      57.315514\n",
       "         ...    \n",
       "730    42.421331\n",
       "731    35.877332\n",
       "732    27.787151\n",
       "733    16.393575\n",
       "734    10.419010\n",
       "Length: 735, dtype: float64"
      ]
     },
     "execution_count": 287,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import talib \n",
    "RSV = talib.EMA(cal1,3)\n",
    "RSV"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 288,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0            NaN\n",
       "1            NaN\n",
       "2            NaN\n",
       "3            NaN\n",
       "4      63.944533\n",
       "         ...    \n",
       "730    34.006621\n",
       "731    34.941977\n",
       "732    31.364564\n",
       "733    23.879070\n",
       "734    17.149040\n",
       "Length: 735, dtype: float64"
      ]
     },
     "execution_count": 288,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "K = talib.EMA(RSV,3)\n",
    "\n",
    "K"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 289,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0            NaN\n",
       "1            NaN\n",
       "2            NaN\n",
       "3            NaN\n",
       "4            NaN\n",
       "         ...    \n",
       "730    26.939247\n",
       "731    31.513503\n",
       "732    33.437721\n",
       "733    30.061870\n",
       "734    24.130891\n",
       "Length: 735, dtype: float64"
      ]
     },
     "execution_count": 289,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "D = talib.MA(K,3)\n",
    "D"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 309,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.series.Series'>\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>code</th>\n",
       "      <th>name</th>\n",
       "      <th>tdate</th>\n",
       "      <th>open</th>\n",
       "      <th>close</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>ktype</th>\n",
       "      <th>id</th>\n",
       "      <th>K</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>513050</td>\n",
       "      <td>中概互联网etf</td>\n",
       "      <td>2018-12-18</td>\n",
       "      <td>1.11</td>\n",
       "      <td>1.107</td>\n",
       "      <td>1.113</td>\n",
       "      <td>1.103</td>\n",
       "      <td>101</td>\n",
       "      <td>206292</td>\n",
       "      <td>39.473922</td>\n",
       "      <td>52.250283</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>513050</td>\n",
       "      <td>中概互联网etf</td>\n",
       "      <td>2018-12-19</td>\n",
       "      <td>1.106</td>\n",
       "      <td>1.086</td>\n",
       "      <td>1.106</td>\n",
       "      <td>1.083</td>\n",
       "      <td>101</td>\n",
       "      <td>206293</td>\n",
       "      <td>27.260226</td>\n",
       "      <td>40.022181</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>513050</td>\n",
       "      <td>中概互联网etf</td>\n",
       "      <td>2018-12-20</td>\n",
       "      <td>1.066</td>\n",
       "      <td>1.069</td>\n",
       "      <td>1.074</td>\n",
       "      <td>1.06</td>\n",
       "      <td>101</td>\n",
       "      <td>206294</td>\n",
       "      <td>19.891745</td>\n",
       "      <td>28.875298</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>513050</td>\n",
       "      <td>中概互联网etf</td>\n",
       "      <td>2018-12-21</td>\n",
       "      <td>1.059</td>\n",
       "      <td>1.068</td>\n",
       "      <td>1.068</td>\n",
       "      <td>1.054</td>\n",
       "      <td>101</td>\n",
       "      <td>206295</td>\n",
       "      <td>16.722522</td>\n",
       "      <td>21.291498</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>513050</td>\n",
       "      <td>中概互联网etf</td>\n",
       "      <td>2018-12-24</td>\n",
       "      <td>1.059</td>\n",
       "      <td>1.06</td>\n",
       "      <td>1.063</td>\n",
       "      <td>1.055</td>\n",
       "      <td>101</td>\n",
       "      <td>206296</td>\n",
       "      <td>13.312086</td>\n",
       "      <td>16.642118</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>730</th>\n",
       "      <td>513050</td>\n",
       "      <td>中概互联网etf</td>\n",
       "      <td>2021-12-13</td>\n",
       "      <td>1.348</td>\n",
       "      <td>1.356</td>\n",
       "      <td>1.368</td>\n",
       "      <td>1.348</td>\n",
       "      <td>101</td>\n",
       "      <td>207016</td>\n",
       "      <td>34.006621</td>\n",
       "      <td>26.939247</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>731</th>\n",
       "      <td>513050</td>\n",
       "      <td>中概互联网etf</td>\n",
       "      <td>2021-12-14</td>\n",
       "      <td>1.345</td>\n",
       "      <td>1.333</td>\n",
       "      <td>1.348</td>\n",
       "      <td>1.333</td>\n",
       "      <td>101</td>\n",
       "      <td>207017</td>\n",
       "      <td>34.941977</td>\n",
       "      <td>31.513503</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>732</th>\n",
       "      <td>513050</td>\n",
       "      <td>中概互联网etf</td>\n",
       "      <td>2021-12-15</td>\n",
       "      <td>1.337</td>\n",
       "      <td>1.324</td>\n",
       "      <td>1.34</td>\n",
       "      <td>1.322</td>\n",
       "      <td>101</td>\n",
       "      <td>207018</td>\n",
       "      <td>31.364564</td>\n",
       "      <td>33.437721</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>733</th>\n",
       "      <td>513050</td>\n",
       "      <td>中概互联网etf</td>\n",
       "      <td>2021-12-16</td>\n",
       "      <td>1.319</td>\n",
       "      <td>1.311</td>\n",
       "      <td>1.319</td>\n",
       "      <td>1.308</td>\n",
       "      <td>101</td>\n",
       "      <td>207019</td>\n",
       "      <td>23.879070</td>\n",
       "      <td>30.061870</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>734</th>\n",
       "      <td>513050</td>\n",
       "      <td>中概互联网etf</td>\n",
       "      <td>2021-12-17</td>\n",
       "      <td>1.305</td>\n",
       "      <td>1.282</td>\n",
       "      <td>1.305</td>\n",
       "      <td>1.278</td>\n",
       "      <td>101</td>\n",
       "      <td>207020</td>\n",
       "      <td>17.149040</td>\n",
       "      <td>24.130891</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>729 rows × 11 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       code      name       tdate   open  close   high    low ktype      id  \\\n",
       "6    513050  中概互联网etf  2018-12-18   1.11  1.107  1.113  1.103   101  206292   \n",
       "7    513050  中概互联网etf  2018-12-19  1.106  1.086  1.106  1.083   101  206293   \n",
       "8    513050  中概互联网etf  2018-12-20  1.066  1.069  1.074   1.06   101  206294   \n",
       "9    513050  中概互联网etf  2018-12-21  1.059  1.068  1.068  1.054   101  206295   \n",
       "10   513050  中概互联网etf  2018-12-24  1.059   1.06  1.063  1.055   101  206296   \n",
       "..      ...       ...         ...    ...    ...    ...    ...   ...     ...   \n",
       "730  513050  中概互联网etf  2021-12-13  1.348  1.356  1.368  1.348   101  207016   \n",
       "731  513050  中概互联网etf  2021-12-14  1.345  1.333  1.348  1.333   101  207017   \n",
       "732  513050  中概互联网etf  2021-12-15  1.337  1.324   1.34  1.322   101  207018   \n",
       "733  513050  中概互联网etf  2021-12-16  1.319  1.311  1.319  1.308   101  207019   \n",
       "734  513050  中概互联网etf  2021-12-17  1.305  1.282  1.305  1.278   101  207020   \n",
       "\n",
       "             K          D  \n",
       "6    39.473922  52.250283  \n",
       "7    27.260226  40.022181  \n",
       "8    19.891745  28.875298  \n",
       "9    16.722522  21.291498  \n",
       "10   13.312086  16.642118  \n",
       "..         ...        ...  \n",
       "730  34.006621  26.939247  \n",
       "731  34.941977  31.513503  \n",
       "732  31.364564  33.437721  \n",
       "733  23.879070  30.061870  \n",
       "734  17.149040  24.130891  \n",
       "\n",
       "[729 rows x 11 columns]"
      ]
     },
     "execution_count": 309,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(type(K))\n",
    "df_cp = df_code.copy()\n",
    "\n",
    "df_cp.insert(df_cp.shape[1],'K',K)\n",
    "df_cp.insert(df_cp.shape[1],'D',D)\n",
    "df_cp = df_cp.dropna()\n",
    "df_cp\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 311,
   "metadata": {},
   "outputs": [],
   "source": [
    "import mplfinance as mpf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 371,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "DatetimeIndex: 60 entries, 2021-09-16 to 2021-12-17\n",
      "Data columns (total 10 columns):\n",
      " #   Column  Non-Null Count  Dtype  \n",
      "---  ------  --------------  -----  \n",
      " 0   code    60 non-null     object \n",
      " 1   name    60 non-null     object \n",
      " 2   Open    60 non-null     float64\n",
      " 3   Close   60 non-null     float64\n",
      " 4   High    60 non-null     float64\n",
      " 5   Low     60 non-null     float64\n",
      " 6   ktype   60 non-null     object \n",
      " 7   id      60 non-null     int64  \n",
      " 8   K       60 non-null     float64\n",
      " 9   D       60 non-null     float64\n",
      "dtypes: float64(6), int64(1), object(3)\n",
      "memory usage: 5.2+ KB\n"
     ]
    }
   ],
   "source": [
    "df_cp2 = df_cp.rename(columns={\"open\":\"Open\",\"close\":\"Close\",\"high\":\"High\",\"low\":\"Low\"}).tail(60)\n",
    "df_cp2[\"Open\"]= df_cp2[\"K\"].astype(\"float\")\n",
    "\n",
    "\n",
    "df_cp2[\"Close\"] = df_cp2[\"D\"].astype(\"float\")\n",
    "df_cp2[\"High\"] = df_cp2[\"D\"].astype(\"float\")\n",
    "df_cp2[\"Low\"] = df_cp2[\"K\"].astype(\"float\")\n",
    "df_cp2['tdate'] = pd.to_datetime(df_cp2['tdate'] )\n",
    "df_cp2.set_index(\"tdate\",inplace=True)\n",
    "df_cp2.info()\n",
    "mc = mpf.make_marketcolors(\n",
    "    up=\"red\",  # 上涨K线的颜色\n",
    "    down=\"green\",  # 下跌K线的颜色\n",
    "    edge=\"black\",  # 蜡烛图箱体的颜色\n",
    "    volume=\"blue\",  # 成交量柱子的颜色\n",
    "    wick=\"black\"  # 蜡烛图影线的颜色\n",
    ")\n",
    "\n",
    "s = mpf.make_mpf_style(\n",
    "    gridaxis='both',\n",
    "    gridstyle='-.',\n",
    "    y_on_right=True,\n",
    "    marketcolors=mc,\n",
    "    edgecolor='b',\n",
    "    figcolor='r',\n",
    "    facecolor='y', \n",
    "    gridcolor='c')\n",
    "\n",
    "\n",
    "apdict = mpf.make_addplot(df_cp2[['D','K']])\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 373,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%capture\n",
    "## %%capture blocks jupyter notebook output; plots are saved to files anyway:\n",
    "save = dict(fname='./tsave30.jpg',dpi=30,pad_inches=0.25)\n",
    "\n",
    "mpf.plot(df_cp2,volume=False,addplot=apdict,type='candle',figscale=1.5,figratio=(4,1),style=\"binance\",savefig=save)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "auto commit SKDJ task picture：2021-12-22 15:13:58\n"
     ]
    }
   ],
   "source": [
    "import time\n",
    "import os\n",
    "import random\n",
    "data = os.system(\"git add -f ./tmp/*\")\n",
    "\n",
    "commit_msg = \"auto commit SKDJ task picture：\" + time.strftime(\"%Y-%m-%d %H:%M:%S\") \n",
    "\n",
    "print(commit_msg)\n",
    "# cmmitStatus = os.system(\"git commit -m '%s'\"% commit_msg)\n",
    "# pushStatus = os.system(\"git push\")\n",
    "# print(cmmitStatus)\n",
    "# print(pushStatus)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[master 42377cf] auto commit SKDJ task picture：2021-12-22 15:32:29\n",
      " 79 files changed, 0 insertions(+), 0 deletions(-)\n",
      " create mode 100644 \"tmp/159707\\346\\227\\245\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/159745\\346\\227\\245\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/159816\\345\\221\\250\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/159816\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/159841\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/159842\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/159848\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/159851\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/159865\\346\\227\\245\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/159867\\346\\227\\245\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/159869\\345\\221\\250\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/159890\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/159905\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/159906\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/159916\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/159919\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/159923\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/159925\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/159965\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/159968\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/159979\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/159980\\345\\221\\250\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/159981\\345\\221\\250\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/159997\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/510020\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/510050\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/510110\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/510180\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/510300\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/510310\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/510330\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/510350\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/510360\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/510370\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/510380\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/510390\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/510530\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/510600\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/510680\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/510800\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/510810\\346\\227\\245\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/510850\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/511010\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/512040\\346\\227\\245\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/512040\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/512200\\346\\227\\245\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/512550\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/512590\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/512910\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/512960\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/513080\\345\\221\\250\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/513590\\346\\227\\245\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/513800\\345\\221\\250\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/513880\\345\\221\\250\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/515000\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/515060\\346\\227\\245\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/515100\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/515130\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/515190\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/515230\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/515260\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/515300\\346\\227\\245\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/515330\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/515380\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/515390\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/515600\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/515670\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/515860\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/515870\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/515890\\346\\227\\245\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/516000\\345\\221\\250\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/516010\\345\\221\\250\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/516050\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/516190\\345\\221\\250\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/516200\\346\\234\\210\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/516670\\346\\227\\245\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/516700\\345\\221\\250\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/516760\\346\\227\\245\\347\\272\\277SKDJ.jpg\"\n",
      " create mode 100644 \"tmp/516770\\345\\221\\250\\347\\272\\277SKDJ.jpg\"\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "remote: Powered by \u001b[01;33mGITEE.COM \u001b[0m[\u001b[01;35mGNK-6.2\u001b[0m]\u001b[0m        \n",
      "To gitee.com:shenge08/python_spider.git\n",
      "   ec60c38..42377cf  master -> master\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#data = os.system(\"rm -rf ./tmp/*\")\n",
    "data = os.system(\"git add -f ./tmp/*\")\n",
    "\n",
    "commit_msg = \"auto commit SKDJ task picture：\" + time.strftime(\"%Y-%m-%d %H:%M:%S\") \n",
    "os.system(\"git commit -m '%s'\" % commit_msg)\n",
    "os.system(\"git push\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "import json\n",
    "\n",
    "import time\n",
    "import hmac\n",
    "import hashlib\n",
    "import base64\n",
    "import urllib.parse\n",
    "'''\n",
    "{\n",
    "     \"msgtype\": \"markdown\",\n",
    "     \"markdown\": {\n",
    "         \"title\":\"杭州天气\",\n",
    "         \"text\": \"#### 杭州天气 @150XXXXXXXX \\n > 9度，西北风1级，空气良89，相对温度73%\\n > ![screenshot](https://img.alicdn.com/tfs/TB1NwmBEL9TBuNjy1zbXXXpepXa-2400-1218.png)\\n > ###### 10点20分发布 [天气](https://www.dingtalk.com) \\n\"\n",
    "     },\n",
    "      \"at\": {\n",
    "          \"atMobiles\": [\n",
    "              \"150XXXXXXXX\"\n",
    "          ],\n",
    "          \"atUserIds\": [\n",
    "              \"user123\"\n",
    "          ],\n",
    "          \"isAtAll\": false\n",
    "      }\n",
    " }\n",
    "'''\n",
    "def sendMarkDownMsg(url,sec,msg,title):\n",
    "    #time.sleep(5000)\n",
    "    url = url +\"&timestamp=%s&sign=%s\"\n",
    "    headers = {\"content-type\": 'application/json'}\n",
    "    timestamp = str(round(time.time() * 1000))\n",
    "    secret = sec\n",
    "    secret_enc = secret.encode('utf-8')\n",
    "    string_to_sign = '{}\\n{}'.format(timestamp, secret)\n",
    "    string_to_sign_enc = string_to_sign.encode('utf-8')\n",
    "    hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest()\n",
    "    sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))\n",
    "    url = url % (timestamp,sign)\n",
    "    data = {}\n",
    "    data['msgtype'] = \"markdown\"\n",
    "    markdown = {}\n",
    "    markdown[\"title\"] = title\n",
    "    markdown[\"text\"] = msg\n",
    "    data['markdown'] =markdown\n",
    "    response = requests.post(url=url,data=json.dumps(data),headers=headers)\n",
    "    return response;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[{'title': '南方中证房地产ETF(512200:)', 'text': '### 南方中证房地产ETF(512200:)出现买点 \\n  ![SKDJ](https://gitee.com/shenge08/python_spider/raw/master/tmp/512200日线SKDJ.jpg)\\n '}, {'title': '华夏中证全指房地产ETF(515060:)', 'text': '### 华夏中证全指房地产ETF(515060:)出现买点 \\n  ![SKDJ](https://gitee.com/shenge08/python_spider/raw/master/tmp/515060日线SKDJ.jpg)\\n '}, {'title': '国泰中证全指建筑材料ETF(159745:)', 'text': '### 国泰中证全指建筑材料ETF(159745:)出现买点 \\n  ![SKDJ](https://gitee.com/shenge08/python_spider/raw/master/tmp/159745日线SKDJ.jpg)\\n '}, {'title': '汇添富中证上海国企ETF(510810:)', 'text': '### 汇添富中证上海国企ETF(510810:)出现买点 \\n  ![SKDJ](https://gitee.com/shenge08/python_spider/raw/master/tmp/510810日线SKDJ.jpg)\\n '}, {'title': '华宝中证800地产ETF(159707:)', 'text': '### 华宝中证800地产ETF(159707:)出现买点 \\n  ![SKDJ](https://gitee.com/shenge08/python_spider/raw/master/tmp/159707日线SKDJ.jpg)\\n '}, {'title': '平安中证畜牧养殖ETF(516760:)', 'text': '### 平安中证畜牧养殖ETF(516760:)出现买点 \\n  ![SKDJ](https://gitee.com/shenge08/python_spider/raw/master/tmp/516760日线SKDJ.jpg)\\n '}, {'title': '鹏华中证畜牧养殖ETF(159867:)', 'text': '### 鹏华中证畜牧养殖ETF(159867:)出现买点 \\n  ![SKDJ](https://gitee.com/shenge08/python_spider/raw/master/tmp/159867日线SKDJ.jpg)\\n '}, {'title': '招商中证畜牧养殖ETF(516670:)', 'text': '### 招商中证畜牧养殖ETF(516670:)出现买点 \\n  ![SKDJ](https://gitee.com/shenge08/python_spider/raw/master/tmp/516670日线SKDJ.jpg)\\n '}, {'title': '国泰中证畜牧养殖ETF(159865:)', 'text': '### 国泰中证畜牧养殖ETF(159865:)出现买点 \\n  ![SKDJ](https://gitee.com/shenge08/python_spider/raw/master/tmp/159865日线SKDJ.jpg)\\n '}, {'title': '嘉实沪深300红利低波动ETF(515300:)', 'text': '### 嘉实沪深300红利低波动ETF(515300:)出现买点 \\n  ![SKDJ](https://gitee.com/shenge08/python_spider/raw/master/tmp/515300日线SKDJ.jpg)\\n '}, {'title': '博时红利ETF(515890:)', 'text': '### 博时红利ETF(515890:)出现买点 \\n  ![SKDJ](https://gitee.com/shenge08/python_spider/raw/master/tmp/515890日线SKDJ.jpg)\\n '}, {'title': '富国中证价值ETF(512040:)', 'text': '### 富国中证价值ETF(512040:)出现买点 \\n  ![SKDJ](https://gitee.com/shenge08/python_spider/raw/master/tmp/512040日线SKDJ.jpg)\\n '}, {'title': '鹏华中证港股通消费主题ETF(513590:)', 'text': '### 鹏华中证港股通消费主题ETF(513590:)出现买点 \\n  ![SKDJ](https://gitee.com/shenge08/python_spider/raw/master/tmp/513590日线SKDJ.jpg)\\n '}]\n",
      "{\"errcode\":0,\"errmsg\":\"ok\"}\n",
      "{\"errcode\":0,\"errmsg\":\"ok\"}\n",
      "{\"errcode\":0,\"errmsg\":\"ok\"}\n",
      "{\"errcode\":0,\"errmsg\":\"ok\"}\n",
      "{\"errcode\":0,\"errmsg\":\"ok\"}\n",
      "{\"errcode\":0,\"errmsg\":\"ok\"}\n",
      "{\"errcode\":0,\"errmsg\":\"ok\"}\n",
      "{\"errcode\":0,\"errmsg\":\"ok\"}\n",
      "{\"errcode\":0,\"errmsg\":\"ok\"}\n",
      "{\"errcode\":0,\"errmsg\":\"ok\"}\n",
      "{\"errcode\":0,\"errmsg\":\"ok\"}\n",
      "{\"errcode\":0,\"errmsg\":\"ok\"}\n",
      "{\"errcode\":0,\"errmsg\":\"ok\"}\n"
     ]
    }
   ],
   "source": [
    "\n",
    "sql = \"SELECT  DISTINCT buy.code,fund.fund_name FROM %s  as buy  LEFT JOIN shenge_money_fund_listed_open_ended_fund as fund ON buy.code = fund.fund_code  WHERE buy.ktype=%s  AND buy.flag='%s' \" % ('shenge_money_buy_point',101,time.strftime(\"%Y-%m-%d\"))\n",
    "df1= pd.read_sql(sql=sql,con=conn)\n",
    "\n",
    "\n",
    "df1['url'] =\"https://gitee.com/shenge08/python_spider/raw/master/tmp/\"+df1['code']+\"日线\"+\"SKDJ.jpg\"\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "def convertDfToMarkDown(df):\n",
    "    markDowns =[]\n",
    "    for index,row in df.iterrows():\n",
    "        mark  = {}\n",
    "        mark['title'] = row['fund_name']+\"(\"+row['code']+\":\"+\")\"\n",
    "        mark['text'] = \"### %s出现买点 \\n  ![SKDJ](%s)\\n \" % (mark['title'] ,row['url'])\n",
    "        markDowns.append(mark)\n",
    "    return markDowns\n",
    "\n",
    "msgs = convertDfToMarkDown(df1)\n",
    "print(msgs)\n",
    "\n",
    "url ='https://oapi.dingtalk.com/robot/send?access_token=8d486ae88f342d07a6f677f52434efda8eb3932091a9fc81e42125d3150dda23'\n",
    "sec = \"SECe1a904be6be4b7530987c5f38367de15964a7afaed5ce0fadddfd739ba5dc928\"\n",
    "for msg in msgs:\n",
    "    aa= sendMarkDownMsg(url=url,sec=sec,title=msg['title'] ,msg=msg['text'])\n",
    "    print(aa.text)\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
  },
  "kernelspec": {
   "display_name": "Python 3.7.3 64-bit",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
